package com.cxf.windex.rest.minaf;

import com.cxf.windex.base.msg.ObjectRestResponse;
import com.cxf.windex.base.rest.BaseRestController;
import com.cxf.windex.biz.BResourcesBiz;
import com.cxf.windex.entity.BResouces;
import com.cxf.windex.entity.BShop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: business_needs
 * @description: FResourcesController
 * @author: chenxf
 * @create: 2018-11-05 15:26
 **/
@Api(tags = {"村广通[小程序-福] - 资源方接口"})
@Controller
@RequestMapping("userf/resources")
public class FResourcesController extends BaseRestController<BResourcesBiz,BResouces> {

  @ApiOperation(value = "获取当前用户资源信息", notes = "获取当前用户资源信息")
  @RequestMapping(value = "/getInfo", method = RequestMethod.GET)
  @ApiImplicitParams({
      @ApiImplicitParam(name = "wxopenid", value = "微信 openID", required = true, paramType = "query", dataType = "String")
  })
  @ResponseBody
  public ObjectRestResponse getInfo(String wxopenid){
    BResouces entity=baseBiz.getInfo(wxopenid);
    if(entity==null){
      return new ObjectRestResponse("找不到相关信息").rel(false);
    }
    return new ObjectRestResponse("查询成功").rel(true).result(entity);
  }
  @ApiOperation(value = "保存资源信息", notes = "保存资源信息")
  @RequestMapping(value = "/save", method = RequestMethod.POST)
  @ResponseBody
  public ObjectRestResponse save(BResouces entity){
    baseBiz.save(entity);
    return new ObjectRestResponse("保存成功").rel(true);
  }
}
